package com.lht.leetcodeDemo;

import org.junit.Test;

/**
 * @author Eric
 * @version 1.0
 * @date 2019-05-28
 */
public class FactorialTrailingZeroes {


    @Test
    public void test() {
        int n = jiecheng(10);
        int sum = 0;
        while (n != 0 && n % 10 == 0) {
            sum++;
            n /= 10;
        }
        System.out.println("sum:" + sum);
        System.out.println(new FactorialTrailingZeroes().trailingZeroes(20));
    }

    public int trailingZeroes(int n) {
        int sum = 0;
        sum += (n / 5);
        return sum;
    }

    public int jiecheng(int n) {
        int sum = 1;
        for (int i = 1; i <= n; i++) {
            sum *= i;
        }
        System.out.println("阶乘：" + sum);
        return sum;
    }
}
